//
//  Person.m
//  OC_JiangMingjun
//
//  Created by apple on 16/4/29.
//  Copyright © 2016年 apple. All rights reserved.
//

#import "Person.h"
#import "NSString+Characters.h"

@implementation Person

#pragma mark - Creating and Init

+ (instancetype)personWithName:(NSString *)name
                           sex:(NSString *)sex
                           age:(NSInteger)age
                   phoneNumber:(NSString *)number{


    Person *per = [[Person alloc] init];
    
    per.name = name;
    per.sex = sex;
    per.age = age;
    per.phoneNumber = number;
    per.group = [NSString getFirstChar:name];

    return [per autorelease];
}


#pragma mark - Dealloc

- (void)dealloc{

    [_name release];
    [_sex release];
    [_phoneNumber release];
    [_group release];

    [super dealloc];

}




#pragma mark - Function

- (NSComparisonResult)compareWithSex:(Person *)another{

    return [self.sex compare:another.sex];

}


- (NSString *)description{

    return [NSString stringWithFormat:@"name : %@ , sex : %@ , age: %ld , number: %@",_name,_sex,_age,_phoneNumber];

}

@end
